import React, { lazy } from "react";
import { RouterType } from "../Type/index";
import { WapHomeO, AppsO, CartO, UserCircleO } from "@react-vant/icons";
// 二级路由
const Home = lazy(() => import("../pages/Home/index"));
const Cate = lazy(() => import("../pages/Cate/index"));
const Cart = lazy(() => import("../pages/Cart/index"));
const User = lazy(() => import("../pages/User/index"));
// 一级路由
const Login = lazy(() => import("../pages/Login/index"));
const Layout = lazy(() => import("../pages/Layout/index"));
const Detail = lazy(() => import("../pages/Detail/index"));
const Search = lazy(() => import("../pages/Search/index"));
// 二级路由
export const ChildrenRouter: RouterType[] = [
  {
    path: "/",
    element: <Home />,
    meta: {
      label: "首页",
      icon: <WapHomeO />,
    },
  },
  {
    path: "/cate",
    element: <Cate />,
    meta: {
      label: "分类",
      icon: <AppsO />,
    },
  },
  {
    path: "/cart",
    element: <Cart />,
    meta: {
      label: "购物车",
      icon: <CartO />,
    },
  },
  {
    path: "/user",
    element: <User />,
    meta: {
      label: "个人中心",
      icon: <UserCircleO />,
    },
  },
];
// 一级路由
const router: RouterType[] = [
  {
    path: "/login",
    element: <Login />,
    meta: {
      label: "登录",
    },
  },
  {
    path: "/",
    element: <Layout />,
    meta: {
      label: "主页",
    },
    children: ChildrenRouter,
  },
  {
    path: "/detail/:id",
    element: <Detail />,
    meta: {
      label: "详情页",
    },
  },
  {
    path: "/search",
    element: <Search />,
    meta: {
      label: "搜索页",
    },
  },
];
export default router;
